package com.googlecode.agscrum.model.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;

@Entity
@SequenceGenerator(name = "status_sequence", sequenceName = "status_sequence")
@NamedQueries(value = { @NamedQuery(name = "Status.searchQuery", query = "select new Status(s.id, s.description, s.order) from Status s ") })
public class Status implements Comparable<Status> {
	@Id
	@GeneratedValue(generator = "status_sequence", strategy = GenerationType.SEQUENCE)
	@Column(name = "id_status")
	private Long id;
	@Column(length = 50, nullable = false)
	private String description;
	@Column(name = "STATUS_ORDER", nullable = false)
	private Integer order;
	@Column(length = 10)
	private String cor;

	public Status(Long id, String description, Integer order) {
		super();
		this.setId(id);
		this.setDescription(description);
		this.setOrder(order);
	}

	public Status() {

	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	public Integer getOrder() {
		return order;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Status other = (Status) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public int compareTo(Status o) {
		// TODO Auto-generated method stub
		return order.compareTo(o.order);
	}

}
